/*
 * Line.hpp
 *
 *  Created on: 05-01-2011
 *      Author: Piotr
 */

#pragma once

#include "Vector.hpp"

/*
 * Two dimensional line which consists of two points (vectors).
 */
class Line
{
	private:
		enum TRI_CLOCK_DIR
		{
			COUNTER_CLOCKWISE, CLOCKWISE, LINE
		};

		Vector start;
		Vector end;

	public:
		enum SIDE_IN_CCW
		{
			POSITIVE, ON, NEGATIVE
		};

		Line(float x0, float y0, float x1, float y1);
		Line(const Vector& start, const Vector& end);

		SIDE_IN_CCW getSide(const Vector& point) const;

		const Vector& getStartPoint() const;
		const Vector& getEndPoint() const;

		float getSquaredLength() const;

		bool intersects(const Line& line) const;

	private:
		float calculateCCWFactor(const Vector& point) const;
		int check_tri_clock_dir(const Vector& pt1, const Vector& pt2, const Vector& pt3) const;
};
